

import {
    toast,
    promptBox
} from 'nc-lightapp-front';

import deepCopy from '../../../../hrpub/common/utils/deep-copy';
import print from '../../../../hrpub/common/utils/print';
import exportHtml from '../../../../hrpub/common/utils/exportHtml';

export default class CommonAction {

    toast = (obj) => {
        toast(obj);
    }

    promptBox =  (obj) => {
        promptBox(obj);
    }

    deepCopy = (...args) => {
        return deepCopy(...args);
    }

    print = (...args) => {
        print(...args);
    }

    exportHtml = (...args) => {
        exportHtml(...args);
    }

    // 通用关闭弹窗
    closeModal = (field) => {
        return () => {
            const {props} = this.comp;
            const {dispatch} = props;

            dispatch({
                type: 'emp/update',
                payload: {
                    [field]: false
                }
            });
        }
    }

    update = (data) => {
        this.comp.props.dispatch({
            type: 'emp/update',
            payload: {
                ...data
            }
        });
    }

}